package com.graduate.game.shop.controller;

import com.alibaba.fastjson.JSON;
import com.graduate.game.shop.pojo.goods;
import com.graduate.game.shop.pojo.orderform;
import com.graduate.game.shop.service.orderformService;
import com.graduate.game.user.pojo.userdata;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.crypto.Data;
import java.sql.Date;
import java.util.List;
import java.util.Map;

@Controller
@ResponseBody
@RequestMapping("/orderform")
@CrossOrigin(origins = "*", maxAge = 3600)
public class orderformController {
    @Autowired
    public orderformService orderformservice;
    @RequestMapping("/add")
    public String getAll(HttpServletRequest request, HttpServletResponse response) throws Exception {
        response.setHeader("Access-Control-Allow-Origin","*");
        String s1 = request.getReader().readLine();
        Map maps =(Map) JSON.parse(s1);
        orderform orderform = new orderform();
        System.out.println(s1);
        Date date = new Date(System.currentTimeMillis()-5400000);
        orderform.setBuyer((String) maps.get("buyer"));
        orderform.setTime(date);
        orderform.setGoodsid(Integer.parseInt(maps.get("goodsid").toString()));
        orderformservice.addform(orderform);
        return "增加记录";
    }
}
